<?php
/*
 * @Author: lokei
 * @Date: 2023-01-02 11:11:11
 * @LastEditors: lokei
 * @LastEditTime: 2023-01-02 11:41:49
 * @Description: 
 */
namespace App\Http\Controllers\Widget;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Widget\ThemeIndexModel;
use Illuminate\Http\Request;

class IndexController extends Controller {
    public function getBanner() {
        $theme = ThemeIndexModel::first();
        if(is_null($theme)) {
            $theme = new ThemeIndexModel();
            $theme->save();
        }
        $res = ResultTool::success();
        $res['data'] = [
            'banner_mode' => $theme->banner_mode,
            'banner_height' => $theme->banner_height
        ];
        return $res;
    }

    public function setBanner(Request $request) {
        $theme = ThemeIndexModel::first();
        $theme->banner_mode = $request->input('banner_mode');
        $theme->banner_height = $request->input('banner_height');
        $theme->save();
        return ResultTool::success();
    }
}